*** REPLICATION TOOLKIT ***

* AUTHORS: CIMINELLI DUVAL FURCERI 

* ARTICLE: EMPLOYMENT PROTECTION DEREGULATION AND LABOR SHARES IN ADVANCED ECONOMIES 

* JOURNAL: REVIEW OF ECONOMICS AND STATISTICS

* OUTPUT: TABLE F1 (Online Appendix)

***************************

cd ""

putexcel set "Tables/F1", modify 

global horizon 6 

************ PREPARE DATASET **********

run "Do files/Clean dataset"

* Value added
gen V = 100*log(va)

* Dependent variables
foreach v in V {
gen `v'1 = `v'-l.`v'
forvalues i = 2 / $horizon {
local sc = `i'-1
gen `v'`i' = f`sc'.`v'-l.`v'
}
}

* Lags dependent variable
foreach v in V {
forvalues l = 1 / 6 {
gen l`l'`v' = l`l'.`v'1
}
}

* Variable = 0 for EOS > 1 and = 1 for EOS < 1
gen eps = 1 
replace eps = 0 if EOS_serv4_OLS > 1

* Variable = 0 for layoff < median and = 1 for EOS < 1
quietly sum layoff_rate, detail
local m = r(p50)
gen m2 = 1
replace m2 = 0 if layoff_rate < `m'

* Generate explanatory variable
gen x = EPLregularworkers*eps*m2

* Lags and forwards of explanatory variables
forvalues l = 1 / 6 {
gen l`l'x = l`l'.x
}
forvalues f = 1 / 5 {
gen f`f'x = f`f'.x
}

* Global for forward variables (Teulings and Zubanov)
global F1x
global F2x f1x
global F3x f1x f2x
global F4x f1x f2x f3x
global F5x f1x f2x f3x f4x
global F6x f1x f2x f3x f4x f5x

* EPL reform temporary contract
gen t = EPLtemporaryworkers*eps*m2

************ ANALYSIS **********

mat mat = J(6,$horizon,.)

forvalues i= 1/$horizon {
* Labor share
quietly reghdfe  Y`i' x l1Y l2Y l3Y l4Y l1x l2x l3x l4x t ${F`i'x}, absorb(id_cross_section i.year#id_country i.year#id_industry) cluster(ifscode year) nocons
matrix results = r(table)
mat mat[1,`i'] = results[1,1]
mat mat[2,`i'] = results[2,1]
mat mat[3,`i'] = results[4,1]
* Value added
quietly reghdfe  V`i' x l1V l2V l3V l4V l1x l2x l3x l4x t ${F`i'x}, absorb(id_cross_section i.year#id_country i.year#id_industry) cluster(ifscode year) nocons
matrix results = r(table)
mat mat[4,`i'] = results[1,1]
mat mat[5,`i'] = results[2,1]
mat mat[6,`i'] = results[4,1]
}

************ SAVE OUTPUT **********

putexcel B4=matrix(mat)
